home *** CD-ROM | disk | FTP | other *** search
- /*
- (C) 1995-96 AROS - The Amiga Replacement OS
- $Id: attemptsemaphoreshared.c,v 1.4 1996/08/13 13:55:58 digulla Exp $
- $Log: attemptsemaphoreshared.c,v $
- Revision 1.4 1996/08/13 13:55:58 digulla
- Replaced __AROS_LA by __AROS_LHA
- Replaced some __AROS_LH*I by __AROS_LH*
- Sorted and added includes
-
- Revision 1.3 1996/08/01 17:41:05 digulla
- Added standard header for all files
-
- Desc:
- Lang: english
- */
- #include "exec_intern.h"
- #include "semaphores.h"
-
- /*****************************************************************************
-
- NAME */
- #include <exec/semaphores.h>
- #include <clib/exec_protos.h>
-
- __AROS_LH1(ULONG, AttemptSemaphoreShared,
-
- /* SYNOPSIS */
- __AROS_LHA(struct SignalSemaphore *, sigSem, A0),
-
- /* LOCATION */
- struct ExecBase *, SysBase, 120, Exec)
-
- /* FUNCTION
- Tries to get a shared lock on a signal semaphore. If the lock cannot
- be obtained false is returned. There may be more than one shared lock
- at a time but an exclusive lock prevents all other locks. The lock
- must be released with ReleaseSemaphore().
-
- INPUTS
- sigSem - pointer to semaphore structure
-
- RESULT
- True if the semaphore could be obtained, false otherwise.
-
- NOTES
-
- EXAMPLE
-
- BUGS
-
- SEE ALSO
- ReleaseSemaphore()
-
- INTERNALS
-
- HISTORY
- 29-10-95 digulla automatically created from
- exec_lib.fd and clib/exec_protos.h
-
- *****************************************************************************/
- {
- __AROS_FUNC_INIT
- __AROS_BASE_EXT_DECL(struct ExecBase *,SysBase)
- LONG ret=0;
-
- /* Arbitrate for the semaphore structure */
- Forbid();
-
- /*
- If the semaphore is free, shared locked or owned by the current task
- it's possible to get another lock.
- */
- if(sigSem->ss_NestCount<=0||sigSem->ss_Owner==SysBase->ThisTask)
- {
- /* Get it and return success */
- ObtainSemaphoreShared(sigSem);
- ret=1;
- }
-
- /* All done. */
- Permit();
- return ret;
- __AROS_FUNC_EXIT
- } /* AttemptSemaphoreShared */
-
-